/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sunspotworld;

import com.sun.spot.sensorboard.EDemoBoard;
import java.io.IOException;
import org.sunspotworld.datawrappers.DataWrapperVector;
import org.sunspotworld.mydatawrappers.LightPacket;
import org.sunspotworld.sensortasks.SensorTask;

/**
 *
 * @author me
 */
public class LightTask extends SensorTask {
    
    public LightTask(long sample) {
        super.sampleInterval = sample;
    }

    private LightTask(long sample, long id) {
        super.sampleInterval = sample;
        super.id = id;
    }

    protected SensorTask copy() {
        SensorTask task = (SensorTask)(new LightTask(super.sampleInterval, super.id));
        task.setRepeat(super.repeating);
        return task;
    }

    public void runTask() {
        try {
            LightPacket pkt = new LightPacket(EDemoBoard.getInstance().getLightSensor().getAverageValue());
            DataWrapperVector.getInstance().add(pkt);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
